<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true">
      <el-form-item label="领料单号" >
        <el-input
          v-model="queryParams.roleName"
          placeholder="请输入领料单号"
          clearable
          size="small"
          style="width: 240px"
        />
      </el-form-item>
      <el-form-item label="领料类型" >
        <el-select
          v-model="queryParams.statusa"
          placeholder="领料类型"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in lllxArr"
            :key="dict.dictValue"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>

      </el-form-item>
      <el-form-item label="审核状态" >
        <el-select
          v-model="queryParams.status"
          placeholder="审核状态"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>

      </el-form-item>
      <el-form-item label="领料日期">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-checkbox v-model="queryParams.checked" >我审核的</el-checkbox>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="">搜索</el-button>
        <el-button type="success" icon="el-icon-plus" size="mini" @click="cgjhadd">添加</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="roleList" stripe >
      <el-table-column align="center" type="index" label="序号"  width="55"  />
      <el-table-column align="center" label="申请单号" property="jhdh" width="150" >
        <template slot-scope="scope" style="text-align: center">
          <span style="color: #2196F3;cursor: pointer" @click="xingqing(scope.row.jhdh)">{{scope.row.jhdh}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="申请人"   property="biaoti" :show-overflow-tooltip="true"  ></el-table-column>
      <el-table-column align="center" label="申请时间" property="cglx" :show-overflow-tooltip="true"  ></el-table-column>
      <el-table-column align="center" label="申请类型"  property="sqlx" :show-overflow-tooltip="true"  >
        <template slot-scope="scope" style="text-align: center">
          <div style="background:#78BF34  ;color: white;width: 54px;height: 22px;display: inline-block" v-show="scope.row.sqlx=='1'" >维修</div>
          <div style="background:#9E71DC  ;color: white;width: 54px;height: 22px;display: inline-block" v-show="scope.row.sqlx=='2'">养护</div>
          <div style="background:#DEA11E  ;color: white;width: 54px;height: 22px;display: inline-block" v-show="scope.row.sqlx=='3'">其他</div>
        </template>
      </el-table-column>
      <el-table-column align="center" label="备注"   property="biaoti" :show-overflow-tooltip="true"  ></el-table-column>
      <el-table-column align="center" label="当前节点"   property="biaoti" :show-overflow-tooltip="true"  ></el-table-column>
      <el-table-column align="center" label="审核状态"  property="spzt" :show-overflow-tooltip="true"  >
        <template slot-scope="scope" style="text-align: center">
          <div style="background:#78BF34  ;color: white;width: 54px;height: 22px;display: inline-block" v-show="scope.row.spzt=='1'" >进行中</div>
          <div style="background:#9E71DC  ;color: white;width: 54px;height: 22px;display: inline-block" v-show="scope.row.spzt=='2'">已结束</div>
          <div style="background:#DEA11E  ;color: white;width: 54px;height: 22px;display: inline-block" v-show="scope.row.spzt=='3'">未提交</div>
        </template>
      </el-table-column>
      <el-table-column align="center" label="审核结束时间"   property="biaoti" :show-overflow-tooltip="true"  ></el-table-column>
      <el-table-column
        label="操作"
        align="center"
        width="200">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary"
            icon="el-icon-edit"
            @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            icon="el-icon-delete"
            @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
  import { listRole, getRole, delRole, addRole, updateRole, exportRole, dataScope, changeRoleStatus } from "@/api/system/role";


  export default {
    name: "Role",
    data() {
      return {
        // 遮罩层
        loading: false,
        // 总条数
        total: 0,
        // 角色表格数据
        roleList: [
          { sqlx:'1',jhdh:'CGJH2020000265',biaoti:'测试数据',cglx:'网购',cgsl:'99',jhje:'8888',cjrq:'',cjren:'季明聪',beizhu:'备注测试',dqjd:'当前节点',spzt:'1',spjssj:'2020-10-02'},
          { sqlx:'2',jhdh:'CGJH2020000264',biaoti:'测试数据',cglx:'网购',cgsl:'99',jhje:'8888',cjrq:'',cjren:'季明聪',beizhu:'备注测试',dqjd:'当前节点',spzt:'2',spjssj:'2020-10-02'},
          { sqlx:'3',jhdh:'CGJH2020000263',biaoti:'测试数据',cglx:'网购',cgsl:'99',jhje:'8888',cjrq:'',cjren:'季明聪',beizhu:'备注测试',dqjd:'当前节点',spzt:'3',spjssj:'2020-10-02'}
        ],
        // 日期范围
        dateRange: [],
        //领料类型
        lllxArr:[
          { value: '1',label: '维修'},
          { value: '2',label: '养护'},
          { value: '3',label: '其他'},
        ],
        // 状态数据字典
        statusOptions: [
          { value: '1',label: '进行中'},
          { value: '2',label: '已结束'},
        ],
        // 数据范围选项
        dataScopeOptions: [
          {
            value: "1",
            label: "全部数据权限"
          },
          {
            value: "2",
            label: "自定数据权限"
          },
          {
            value: "3",
            label: "本部门数据权限"
          },
          {
            value: "4",
            label: "本部门及以下数据权限"
          },
          {
            value: "5",
            label: "仅本人数据权限"
          }
        ],
        // 菜单列表
        menuOptions: [],
        // 部门列表
        deptOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          roleName: undefined,
          roleKey: undefined,
          status: undefined,
          checked:true
        },
        // 表单参数
        form: {},
        defaultProps: {
          children: "children",
          label: "label"
        },
      };
    },
    created() {

    },
    methods: {
      /** 查询角色列表 */
      getList() {
        this.loading = true;
        listRole(this.addDateRange(this.queryParams, this.dateRange)).then(
          response => {
            this.roleList = response.rows;
            this.total = response.total;
            this.loading = false;
          }
        );
      },
      //表格编辑
      handleEdit:function (index,row) {
        console.log(row)
        var obj={
          name:'采购计划'
        }
        this.$router.push({path:'/consumable/llsqAdd',query:{data:obj}});
      },
      //删除
      handleDelete:function (index,row) {
        this.$confirm('确认删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          });
        });
      },
      //采购计划
      cgjhadd:function () {
        console.log('tianjia')
        this.$router.push({path:'/consumable/llsqAdd',query:{userid:'55555'}});
      },
      //详情点击
      xingqing:function (row) {
        console.log(row)
        this.$router.push({path:'/consumable/llsqXQ',query:{userid:row}});
      },

    }
  };
</script>
